---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: client
  namespace: px-protocol-loadtest
spec:
  replicas: 1
  selector:
    matchLabels:
      name: client
  template:
    metadata:
      labels:
        name: client
    spec:
      initContainers:
      - name: server-wait
        # yamllint disable-line rule:line-length
        image: gcr.io/pixie-oss/pixie-dev-public/curl:multiarch-7.87.0@sha256:f7f265d5c64eb4463a43a99b6bf773f9e61a50aaa7cefaf564f43e42549a01dd
        # yamllint disable rule:indentation rule:line-length
        command: ['sh', '-c', 'set -xe;
          URL="http://${SERVICE_NAME}:${SERVICE_PORT}/";
          until [ $(curl -m 0.5 -s -o /dev/null -w "%{http_code}" -X POST -H "Content-Type: application/json" --data {} ${URL}) -eq 200 ]; do
            echo "waiting for ${URL}";
            sleep 2;
          done;']
        # yamllint enable rule:indentation rule:line-length
        env:
        - name: SERVICE_NAME
          value: "server.px-protocol-loadtest.svc.cluster.local"
        - name: SERVICE_PORT
          value: "8080"
      containers:
      - name: app
        image: protocol_loadtest_client_image:latest
        env:
        - name: HTTP_PORT
          value: "8080"
        - name: HTTP_SSL_PORT
          value: "8081"
        - name: HTTP_HOST
          value: "server.px-protocol-loadtest.svc.cluster.local"
        - name: HTTP_PATH
          value: "/"
        envFrom:
        - configMapRef:
            name: px-protocol-loadtest-config
